package com.xdclass.mobile.mobilexdclassredis.controller.bloomFilter;

import com.xdclass.mobile.mobilexdclassredis.RedisService;
import com.xdclass.mobile.mobilexdclassredis.service.BloomFilterService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created whit IntelliJ IDEA
 * User:杨骏杰
 * Date:2021/3/30
 * Time:12:40
 */
@RestController
public class BloomFilterController {

    @Resource
    private BloomFilterService bloomFilterService;

    @Resource
    private RedisService redisService;

    /**
     * guava的布隆过滤器
     * @param id
     * @return
     */
    @RequestMapping("/bloom/idExists")
    public boolean ifExists(int id){
        return bloomFilterService.userIdExists(id);
    }

    /**
     * redis的布隆过滤器
     * @param id
     * @return
     */
    @RequestMapping("/bloom/redisIdExists")
    public boolean redisIdExists(int id){
        return redisService.bloomFilterExists(id);
    }

    /**
     * redis的布隆过滤器
     * @param id
     * @return
     */
    @RequestMapping("/bloom/idAdd")
    public boolean redisIdAdd(int id){
        return redisService.bloomFilterAdd(id);
    }
}
